﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ProjectSem3
{
    public partial class WebForm4 : System.Web.UI.Page
    {
        private DataClassesHealthDataContext dc = new DataClassesHealthDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ImageButtonlogin_Click(object sender, ImageClickEventArgs e)
        {
            string username = this.TextBoxusername.Text;
            string password = this.TextBoxpassword.Text;
            EmpRegister emp;
            if (loginmember(username , password) != null)
            {
               
                  Response.Redirect("index.aspx");
                this.Labelkiemtra.Text = "Success";
                
            }
            else
            {
                this.Labelkiemtra.Text = "Account Not found";
            }

        }
        public EmpRegister loginmember(string username, string password)
        {
            EmpRegister emp = new EmpRegister();
            try
            {
                emp = this.dc.EmpRegisters.Where(em => em.username.Equals(username) && em.password.Equals(password)).ToList().First();
                Session["member"] = emp;
            }
            catch
            {
                emp = null;
            }
            return emp;
        }
    }
}